﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using WaterRevenueMS.Domain.Common.Models;
using System.Web.Mvc;
using System.ComponentModel.DataAnnotations;

namespace WaterRevenueMS.Domain.ViewModels.BaseData.Company
{
    public class CompanyModel : EntityCommon
    {
        public CompanyModel()
        {
            //Enabled = true;
            //IsMenu = true;
            Search = new SearchModel();
            ParentCompanyItems = new List<SelectListItem>() {
                new SelectListItem { Text = "--- 父节点 ---", Value = "0"}, 
            };
        }
        public int Id { get; set; }

        [Display(Name = "公司名称")]
        [Required(ErrorMessage = "公司名称不能为空")]
        [StringLength(50, MinimumLength = 2, ErrorMessage = "公司名称{2}～{1}个字符")]
        public string Name { get; set; }
        public int? ParentId { get; set; }

        [Display(Name = "上级公司")]
        public string ParentName { get; set; }
        public List<SelectListItem> ParentCompanyItems { get; set; }

        [Display(Name = "排序序号")]
        [RegularExpression(@"\d+", ErrorMessage = "必须是数字")]
        public int OrderNo { get; set; }

        public SearchModel Search { get; set; }
    }
    public class SearchModel
    {
        public SearchModel()
        {
            EnabledItems = new List<SelectListItem> { 
                new SelectListItem { Text = "--- 请选择 ---", Value = "-1", Selected = true }, 
                new SelectListItem { Text = "是", Value = "1" }, 
                new SelectListItem { Text = "否", Value = "0" }
            };
            ParentModuleItems = new List<SelectListItem>() {
                new SelectListItem { Text = "--- 请选择 ---", Value = "0"}, 
            };
        }

        public int? ParentId { get; set; }

        [Display(Name = "公司名称")]
        public string Name { get; set; }


        [Display(Name = "上级公司")]
        public string ParentName { get; set; }
        public List<SelectListItem> ParentModuleItems { get; set; }


        [Display(Name = "是否已激活")]
        public bool Enabled { get; set; }

        [Display(Name = "排序序号")]
        public int OrderNo { get; set; }
        public List<SelectListItem> EnabledItems { get; set; }
    }
}
